<template>
 <div id="a">
  <div class="b">
      <div class="bb">
        <img class="c" :src="img1" alt="">
      <span class="d">{{$route.meta.title}}</span>
      <div class="dd"></div>
      </div>
  </div>
  <div class="main">
      <div class="main-pic"><img src="../assets/images/orange.png" alt="" ></div>
    <div class="input-name">
    <input type="text" placeholder="用户名" v-model="reglist.nickname" />
    </div> 
    <div class="input-name">
        <input type="password" placeholder="密码" v-model="reglist.password" />
    </div>
    <div class="input-name">
      <input type="text" placeholder="手机号" v-model="reglist.phone"/>
    </div>
    <button @click="register">注册</button>
    </div> 
 </div>
 
</template>

<script>
import {Register} from '../util/request/api'
export default {
 data() {
 return {
      reglist:{
        phone:'',
        nickname:'',
        password:''
      }
    ,
    img1:require("../assets/images/white.png"),
 };
 },
 methods:{
     register(){
    if(this.reglist.phone=='' ||this.reglist.nickname==''||this.reglist.password==''){
        alert('请输入必填项')
     }else{
        Register(this.reglist)
         .then(res=>{
             if(res.data.code==200){
                 sessionStorage.setItem('isRegister',true)
                 this.$router.push('/login')
             }else{
                 alert(res.data.msg)
             }
         })
         .catch(err=>{
             console.log(err);
         })
     }
     
 }
}}
</script>

<style  scoped>
input{
 border: 0.5px solid #333;
}
button{
    background-color: rgb(255, 96, 63)!important;
}
</style>
